//
//  LoginViewController.m
//  VisitorFacetestingSystem
//
//  Created by 张斌 on 16/7/5.
//  Copyright © 2016年 YueShiKeJi. All rights reserved.
//

#import "LoginViewController.h"
#import "LoadVcManager.h"
#import "AppDelegate.h"
#import "YSDoViewManager.h"
#import "CZNetworkTool.h"
#import "InterFaceDefine.h"
#import "NSArray+Log.h"

@interface LoginViewController ()<UIScrollViewDelegate>
@property (weak, nonatomic) IBOutlet UIScrollView *scrollview;

@property (weak, nonatomic) IBOutlet UIView *MainView;
@property (weak, nonatomic) IBOutlet NSLayoutConstraint *Height;
@property (weak, nonatomic) IBOutlet NSLayoutConstraint *line1;

@property (weak, nonatomic) IBOutlet NSLayoutConstraint *line2;
@property (weak, nonatomic) IBOutlet NSLayoutConstraint *line3;
@property (weak, nonatomic) IBOutlet NSLayoutConstraint *line4;
@property (weak, nonatomic) IBOutlet UITextField *storeId;
@property (weak, nonatomic) IBOutlet UITextField *workId;
@property (weak, nonatomic) IBOutlet UITextField *password;

@end

@implementation LoginViewController

- (void)viewDidLoad {
    [super viewDidLoad];
    
    self.scrollview.delegate = self;
    
    self.navigationController.navigationBarHidden = YES;
    
    //1.创建手势识别对象
    UISwipeGestureRecognizer * leftSwipe = [[UISwipeGestureRecognizer alloc] initWithTarget:self action:@selector(swipe:)];
    
    //2.设置属性
    leftSwipe.direction = UISwipeGestureRecognizerDirectionLeft;
    
    //3.添加到要作用的view上
    [self.view addGestureRecognizer:leftSwipe];
    
    
   
}
- (void) swipe:(UISwipeGestureRecognizer *) swipeGesture
{
    
    [self.navigationController pushViewController:[LoadVcManager sbVCWithsbname:@"FaceLoginViewController"] animated:YES];
}

- (void)viewWillAppear:(BOOL)animated{
    [super viewWillAppear:animated];
    
    self.navigationController.navigationBarHidden = YES;

}

- (void)viewDidLayoutSubviews{
    [super viewDidLayoutSubviews];

    YSDoViewManager * manager = [YSDoViewManager sharedmanager];
    
    [manager setlineWithViews:@[self.line1,self.line2,self.line3,self.line4]];
    
    self.Height.constant = [UIScreen mainScreen].bounds.size.height * 30/667;
    
}



- (void)scrollViewDidScroll:(UIScrollView *)scrollView{
    
}
- (void)scrollViewDidEndDragging:(UIScrollView *)scrollView willDecelerate:(BOOL)decelerate{
    
[self.MainView resignFirstResponder];
    
}


- (IBAction)loginbtn:(id)sender {
    
    NSDictionary* parameters = @{@"storeId":@"wangzhenzhi",@"workId":@"wangzhenzhi", @"password":@"1"};
    
    [[CZNetworkTool sharedManager] POST:password_Login parameters:parameters constructingBodyWithBlock:^(id<AFMultipartFormData>  _Nonnull formData) {
        
    } progress:^(NSProgress * _Nonnull uploadProgress) {
        
    } success:^(NSURLSessionDataTask * _Nonnull task, NSData*  _Nullable responseObject) {
        
        if (responseObject) {
            NSDictionary* dict = [NSJSONSerialization JSONObjectWithData:responseObject options:0 error:nil];
            NSLog(@"%@",dict);
        }

        
        [self presentViewController:[LoadVcManager sbVCWithsbname:@"BeforeHomeViewController"] animated:YES completion:nil];
    } failure:^(NSURLSessionDataTask * _Nullable task, NSError * _Nonnull error) {
        
    }];
    
    
}

- (IBAction)Faceloginbtn:(id)sender {
    
    [self.navigationController pushViewController:[LoadVcManager sbVCWithsbname:@"FaceLoginViewController"] animated:YES];
}


@end
